package xiaoyang.controller.back;

import com.alibaba.fastjson.JSONArray;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import xiaoyang.pojo.AppCategory;
import xiaoyang.service.AppCategoryService;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/category")
public class AppCategooryController {
    @Resource
    private AppCategoryService appCategoryService;
    @ResponseBody
    @RequestMapping("/fenlei1")
    public Object fenlei1(){
        List<AppCategory> categoryLevel1 = appCategoryService.getCategoryLevel1();
        return JSONArray.toJSONString(categoryLevel1);
    }
    @ResponseBody
    @RequestMapping("/fenlei2")
    public Object fenlei2(){
        List<AppCategory> categoryLevel2 = appCategoryService.getCategoryLevel2();
        return JSONArray.toJSONString(categoryLevel2);
    }
    @ResponseBody
    @RequestMapping("/fenlei3")
    public Object fenlei3(@Param("parentId") Integer parentId){
        List<AppCategory> categoryLevel3 = appCategoryService.getCategoryLevel3(parentId);
        return JSONArray.toJSONString(categoryLevel3);
    }

}
